package core {
	/**
	* ...
	* @author Zszen
	*/
	public class ColorCal {
		static function string(rgb:Number) {
			var obj:Object = hex2rgb(rgb);
			return (obj.r+","+obj.g+","+obj.b);
		}
		static function RGB(path:MovieClip, rgb:String):Void {
			//设置影片颜色偏移  格式"10,10,10"
			var c = new Color(path);
			c.setTransform({rb:rgb.split(",")[0], gb:rgb.split(",")[1], bb:rgb.split(",")[2]});
		}
		static function RGBTo(path:MovieClip, rgb:String, divide:Number):Void {
			//设置影片颜色过渡偏移  格式"10,10,10"  循环调用不会直接到指定颜色
			if (divide == null) {
				divide = 2;
			}
			var c = new Color(path);
			var o = new Object();
			o = c.getTransform();
			c.setTransform({rb:o.rb+Math.ceil((rgb.split(",")[0]-o.rb)/divide), gb:o.gb+Math.ceil((rgb.split(",")[1]-o.gb)/divide), bb:o.bb+Math.ceil((rgb.split(",")[2]-o.bb)/divide)});
		}
		static function argb2hex(a:Number, r:Number, g:Number, b:Number) {
			//argb 10->16
			return (a << 24 | r << 16 | g << 8 | b);
		}
		static function rgb2hex(r:Number, g:Number, b:Number) {
			//rgb 10->16
			return (r << 16 | g << 8 | b);
		}
		static function hex2argb(val:Number) {
			var col = {};
			col.a = (val >> 24) & 0xFF;
			col.r = (val >> 16) & 0xFF;
			col.g = (val >> 8) & 0xFF;
			col.b = val & 0xFF;
			return col;
		}
		static function hex2rgb(val:Number) {
			var col = {};
			col.r = (val >> 16) & 0xFF;
			col.g = (val >> 8) & 0xFF;
			col.b = val & 0xFF;
			return col;
		}
	}
}